package main

import (
	"gin_study/libs"
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	router := gin.Default()

	router.StaticFS("/static", http.Dir("./static"))
	//region Ciallo Wondo
	router.GET("/", libs.ResponseJSON)
	router.GET("/baidu", libs.ResponseRedirect)
	//endregion

	// region 请求
	router.GET("/query", libs.Query)
	router.GET("/querys", libs.Querys)
	router.GET("/page/:number", libs.GetPage)
	router.GET("/:keyword/page/:number", libs.KeywordGetPage)
	router.POST("/form", libs.FormRequest)
	router.POST("/raw", libs.Primitive)
	// endregion

	// region 验证
	router.POST("/login", libs.UserLoginValidate)
	router.POST("/validate", libs.CustomValidate)
	// endregion

	// region 文件上传
	router.POST("/upload", libs.UploadDates)
	router.POST("/upload-fragment", libs.UploadDatesCuts)
	router.POST("/uploads", libs.ManyUploadDates)

	// endregion

	//region 中间件
	router.Use(libs.First) // 下面的函数都要这么用 而上面的视图不用
	router.POST("/middleware", libs.Second, libs.Last)
	router.POST("/done", libs.Second)

	//endregion

	router.Run("127.0.0.1:2829")
}
